package cn.edu.zut.dao;

import cn.edu.zut.domain.Contest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ContestDao {

    @Insert("insert into contest(contestName,contestIntroduction,contestTime,contestNote) VALUES(#{contestName},#{contestIntroduction},#{contestTime},#{contestNote})")
    public void add(Contest contest);

    @Select("select * from contest where contestName like CONCAT('%',#{contestName},'%')")
    public List<Contest> queryByName(String contestName);

    @Select("select * from contest")
    public List<Contest> queryAll() ;

    @Update("update contest set contestName=#{contestName},contestIntroduction=#{contestIntroduction},contestTime=#{contestTime},contestNote=#{contestNote} where contestId=#{contestId}")
    public void modifyContest(Contest contest);

    @Delete("delete contest where contestId=#{contestId}")
    public void deleteContest(Contest contest);

    @Select("select * from contest where contestId=#{contestId}")
    public Contest findById(int id);
}
